<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
  <head>
    <base href="<%=basePath%>"> 
    
    <title>My JSP 'index.jsp' starting page</title>
    <script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
    <script >
    Array.prototype.contains=function(e){
			for(var i=0;i<this.length;i++){
				
				if(this[i]==e){
					return true;
				}
			}
			return false;
		}
    $(function(){
    	 var menuIdStr="${roleStr}";
    	 var menuIdArray = menuIdStr.split(",");
    	$("input[type=checkbox]").each(function(){
    		if(menuIdArray.contains(this.value)){
 				this.checked=true;
 			}	
    	});
    	
    	$("input[type=checkbox][name='ck_one']").click(function(){
    		if(this.checked){
    			$("input[id="+this.id+"two]").each(function(){this.checked=true;});
    		}
    		else {
    			$("input[id="+this.id+"two]").each(function(){this.checked=false;});
    		}
    		});
    	
    	$("input[type=checkbox][name='ck_two']").click(function(){
    		if(this.checked){
    			$("#"+this.id.substring(0,this.id.length-3)).attr('checked','checked');
    		}
    		else{
    			if(!$("input[id="+this.id+"]:checked").val()){
    				$("#"+this.id.substring(0,this.id.length-3)).attr('checked',null);
    			}
    		}
    	});
    	
    
			$("#top_ch_checkall").click(function(){
				if(this.checked){
					$("input[type=checkbox]").attr("checked","checked");
				}else{
					$("input[type=checkbox]").removeAttr("checked");
				}
			});
		
    	
    });
    </script>
    	<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
   		 <link rel="stylesheet" type="text/css" href="css/edittable.css"  ></link>  
		<link rel="stylesheet" type="text/css" href="css/validate.css"  ></link>  
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	
	
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    <div class ="div_title">
						<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>角色权限管理 当前角色:${roleInfo.roleName}</span></div>
		  	<div class="div_titleoper"><input type="checkbox" id="top_ch_checkall"/> 全选</div>
				 </div>
				 
				  <form action="RoleServlet.do?flag=xiugai&id=${roleInfo.id}"  name="form1"  id="from1"  method="post">
				 <table class="main_table" >
				       <tr>
				 					<th>一级菜单</th> 	<th>二级菜单</th>	  
				 		</tr>
				 		
				 		<c:forEach var="menu" items="${menulist }">
				 		<tr>
				 				<td><input type="checkbox" id="ck_id${menu.id}" name="ck_one" value="${menu.id}"/>${menu.menuName}_${menu.id}</td>
				 				<td>
				 				<c:forEach var="menu2" items="${menu.menuList }">
				 				<input type="checkbox" id="ck_id${menu.id}two"  name="ck_two"  value="${menu2.id}" />${menu2.menuName } _ck_id${menu.id}two
				 				<br>
				 				</c:forEach>
				 				</td>	
				 		</tr>
				 		</c:forEach>
				</table>
				<br>
			&nbsp; &nbsp; 	<input class="form_btn" type="submit" value="修改"  onclick="return confirm('确定提交吗')"> <label id="result_msg" class="result_msg">${msg}</label>
				</form>
  </body>
</html>